package com.tyk.bookstore.front.order.model.vo;

import com.tyk.bookstore.front.common.core.model.enume.PaymentWay;
import com.tyk.bookstore.front.common.core.util.FileUtil;
import com.tyk.bookstore.front.order.model.emume.CancelReason;
import com.tyk.bookstore.front.order.model.emume.OrderState;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @author tyk
 * @description 订单
 */
@Data
public class OrderVo {

    // OrderDo-订单核心信息

    @Schema(description = "ID")
    private Long id;

    @Schema(description = "订单号")
    private String orderNo;

    @Schema(description = "运单ID")
    private Long waybillId;

    @Schema(description = "订单金额")
    private BigDecimal amount;

    @Schema(description = "订单备注")
    private String note;

    @Schema(description = "仓库ID")
    private Long warehouseId;

    @Schema(description = "仓库名称")
    private String warehouseName;

    @Schema(description = "寄件方地址")
    private String senderAddress;

    @Schema(description = "订单状态[0待支付,1待发货,2待签收,3已完成,4已取消,5已拆单]")
    private OrderState state;

    @Schema(description = "下单时间")
    private LocalDateTime createTime;

    // OrderExtraDo-收件人信息

    @Schema(description = "收件人姓名")
    private String cneeName;

    @Schema(description = "收件人电话")
    private String cneePhone;

    @Schema(description = "收件人区域")
    private Long cneeAreaCode;

    @Schema(description = "收件人区域")
    private String cneeAreaFullName;

    @Schema(description = "收件人地址")
    private String cneeAddress;


    // OrderExtraDo-订单时间轴

    @Schema(description = "支付方式[0商城余额，1支付宝，2微信]")
    private PaymentWay paymentWay;

    @Schema(description = "支付时间")
    private LocalDateTime paymentTime;

    @Schema(description = "订单取消时间")
    private LocalDateTime cancelTime;

    @Schema(description = "订单取消原因")
    private CancelReason cancelReason;

    @Schema(description = "派单时间")
    private LocalDateTime dispatchTime;

    @Schema(description = "签收时间")
    private LocalDateTime signedTime;

    // 订单明细

    @Schema(description = "订单明细")
    private List<OrderDetailVo> detailList;

    @Data
    public static class OrderDetailVo {

        @Schema(description = "书籍ID")
        private Long id;

        @Schema(description = "书籍编号")
        private String bookNo;

        @Schema(description = "书籍封面")
        private String cover;

        @Schema(description = "书籍标题")
        private String title;

        @Schema(description = "购买数量")
        private Long num;

        @Schema(description = "评论ID")
        private Long commentId;

        public OrderDetailVo setCover(String cover) {
            this.cover = FileUtil.fullFilePath(cover);
            return this;
        }
    }
}
